
const user = {
  state: {
    list: []
  },
  mutations: {
    SET_LIST: (state, list) => {
      if(state.list.findIndex(inner=>inner.name === list.name) === -1){
        state.list.push(list)
      }else{
        state.list.splice(state.list.findIndex(inner=>inner.name === list.name), 1,list)
      }
    },
    DELETE_LIST: (state, list) => {
      state.list.splice(state.list.findIndex(inner=>inner.name === list.name), 1)
    }
  },

  actions: {

    // 退出系统
    GetListName({ commit}, name ) {
      commit('SET_LIST', name)
    },
    DeleteListName({ commit}, name ) {
      commit('DELETE_LIST', name)
    },
  }
}

export default user
